package com.zzyl;

import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.data.redis.core.RedisTemplate;

/**
 * @author Administrator
 * @version 1.0
 * @description: TODO
 * @date 2025/9/9 17:56
 */
@SpringBootTest
public class RedisTest2 {
    @Autowired
    private RedisTemplate redisTemplate;

    @Test
    void test1() {
        User user = new User("张三", 18);
        redisTemplate.opsForValue().set("user2", user);

        User user2 = (User)redisTemplate.opsForValue().get("user2");
        System.out.println("user2 = " + user2);
    }
}
